package com.lanou3g.code0510.reflection;

import java.lang.reflect.Method;

/**
 * If there are no bugs, it was created by Chen FengYao on 2018/5/10;
 * Otherwise, I don't know who created it either
 */

public class Test03 {
    public static void main(String[] args) throws Exception {
        // 通过反射调用方法
        Person person = new Person();
        person.setAge(18);
        person.setName("张三");

        Class clazz = Person.class;
        // 调用方法
        Method showMethod = clazz.getDeclaredMethod("show");
        // 让方法能被调用(包括私有方法)
        showMethod.setAccessible(true);
        showMethod.invoke(person);
    }
}
